<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
<center>
    用户名：<input type="text" name="name" id="name"/>
    密码：<input type="password" name="pwd" id="pwd"/>
    手机号：<input type="text" name="tel" id="tel"/>
    <input type="button" value="发送验证码" id="send"/>
    验证码：<input type="text" name="code" id="code"/>
    <input type="button" value="注册" id="sub"/>
</center>
</body>
</html>

<script src="jquery-3.1.1.min.js"></script>
<script type="text/javascript">
    $("#send").click(function(){
        var tel = $("#tel").val();
        if(tel == ""){
            alert("请输入手机号");
            return false;
        }
        $.ajax({
            url:"SendTemplateSMS.php",
            data:{tel:tel},
            dataType:"json",
            type:"post",
            success:function(res){
            console.log(res);
        }
        })
    });
    $("#sub").click(function(){
        var tel = $("#tel").val();
        var code = $("#code").val();
        var name = $("#name").val();
        if(name == ""){
            alert("请输入用户名");
            return false;
        }
        var pwd = $("#pwd").val();
        if(pwd.length<8 || pwd.length>16){
            alert("密码为8-16位");
            return false;
        }
        $.ajax({
            url:"register.php",
            data:{tel;tel,code;code,name;name,pwd;pwd},
            dataType;"json",
            type:"post",
            success:function(res){
                alert(res.msg);
            }
        })
    });
</script>